<extend name='Index/index' />

<block name="main">
    <div class="bg-light lter b-b wrapper-md">
        <h1 class="m-n font-thin h3">编辑用户组</h1>
    </div>


    <form name="myform" class='form-group' action="<{:U('Admin/group_update',array('id'=>$_GET['id']))}>" method="post" onsubmit="return check_form();">
        <div class="list">
            <div style="height:20px"></div>
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="details">
                <tbody>
                    <tr>
                        <td width="20%">
                            <div align="right">组名称：</div>
                        </td>
                        <td width="80%">
                            <input  class="form-control" type="text" name="title" id="title" size="24" value="<{$access.title}>" style="margin-left:10px;width:195px;" />
                        </td>
                    </tr>
                    <tr><td>　</td></tr>
                    <tr>
                        <td>
                            <div align="right">分配的权限：</div>
                        </td>
                        <td>
                            <input type="hidden" id="all" value="1" />
                            <input type="button"  value="全选 / 取消" class="btn btn-info" id="all_checkbox" style="width:150px;margin-left:10px">
                        </td>
                    </tr>
                    <tr><td>　</td></tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>
                            <ul class="first_checkbox" style=" margin-left:10px;">
                                <volist name='all_access' id='vo' key='k'>
                                <li style="list-style:none">
                                    <input name="rules[]" class="check_pid" type="checkbox" id="<{$vo.id}>" value="<{$vo.id}>" <if condition="in_array($vo['id'],$access['rules'])">checked</if> />
                                    <label for="<{$vo.id}>"><{$vo.title}></label><br>
                                            　　┠┄
                                    <volist name='all_access[$k-1]["_child"]' id='v'>
                                            <input name="rules[]" class="check_child" type="checkbox" id="<{$v.id}>" value="<{$v.id}>" <if condition="in_array($v['id'],$access['rules'])">checked</if> />
                                            <label for="<{$v.id}>"><{$v.title}></label>
                                    </volist>
                                </li>
                                </volist>
                            </ul>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="footer">
            <button type="submit" class="btn btn-info" style="min-width:180px;margin:10px 220px">确 认</button>
        </div>
    </form>
    <script>
        var mark = 1;
        $('#all_checkbox').click(function(){
            if (mark) {
                $(':checkbox').prop('checked','true');
                mark = 0;
            }else{
                $(':checkbox').prop('checked',null);
                mark = 1;
            }
        })
        $('input[class=check_pid]').click(function(){
            var mark1 = $(this).parent('li').children('input[class=check_child]').prop('checked');
            if (mark1) {
                $(this).parent('li').children('input[class=check_child]').prop('checked',!mark1)
            }else{
                $(this).parent('li').children('input[class=check_child]').prop('checked',!mark1)
            }
        })

        function check_form(){
            var title = $('#title').val();
            if (title=='') {
                alert('请输入组名');
                return false;
            }
            return true;
        }
    </script>

</block>

